package com.hibase.core.email.entity;

import java.util.*;

/**
 * 邮件对象参数
 */
public class EmailParam {

    private Collection<String> sendTo = new HashSet<>();

    private Map<String,Object> model = new HashMap<>();

    private String subject;

    private Collection<EmailAttach> attaches = new ArrayList<>();

    /**
     * 邮件发送者
     */
    private String emailFrom;

    public EmailParam setSubject(String subject) {
        this.subject = subject;
        return this;
    }

    public EmailParam setModel(String key, Object value) {
        this.model.put(key, value);
        return this;
    }

    public EmailParam setModel(Map<String, Object> model) {
        this.model.putAll(model);
        return this;
    }

    public EmailParam setSendTo(String sendTo) {
        this.sendTo.add(sendTo);
        return this;
    }

    public EmailParam setSendTo(Collection<String> sendTo){
        this.sendTo.addAll(sendTo);
        return this;
    }

    public EmailParam setSendTo(String... sendTo) {
        this.sendTo.addAll(Arrays.asList(sendTo));
        return this;
    }

    public EmailParam setAttach(EmailAttach attach) {
        this.attaches.add(attach);
        return this;
    }

    public EmailParam setAttach(Collection<EmailAttach> attach) {
        this.attaches.addAll(attach);
        return this;
    }

    public EmailParam setAttach(EmailAttach ... attach){
        this.attaches.addAll(Arrays.asList(attach));
        return this;
    }


    public Collection<String> getSendTo() {
        return sendTo;
    }

    public Map<String, Object> getModel() {
        return model;
    }

    public String getSubject() {
        return subject;
    }

    public Collection<EmailAttach> getAttaches() {
        return attaches;
    }

    public static EmailParam build() {
        return new EmailParam();
    }

    public String getEmailFrom() {
        return emailFrom;
    }

    public void setEmailFrom(String emailFrom) {
        this.emailFrom = emailFrom;
    }
}
